#! /bin/sh
#/usr/local/maven/apache-maven-3.8.1/bin/mvn install -Dmaven.test.skip=true dockerfile:build

# 读取当前版本信息
version=$(cat ./version.txt)
echo $version
# 版本号自增1
version=$(($version+1))
echo $version
# 写入文本
cat /dev/null  > ./version.txt
echo $version >>./version.txt


# docker构建
docker buildx build \
  --platform linux/amd64 \
  -t la/helper-api .

# 登录docker容器
docker login ccr.ccs.tencentyun.com --username=100030505577 --password=helper@#2023

#打标签
date_time=`date +%Y%m%d%H%M%S`
echo $date_time
tag="test-$version-$date_time"

docker tag la/helper-api:latest ccr.ccs.tencentyun.com/tcb-100030505577-ozea/ca-zellorrd_helper-api:$tag

#推送
docker push ccr.ccs.tencentyun.com/tcb-100030505577-ozea/ca-zellorrd_helper-api:$tag

echo $tag


# 批量删除本地镜像
# docker rmi --force  $(docker images | grep _helper-api | awk '{print $3}')